import Vue from 'vue'
import Router from 'vue-router'

import MtIndex from '@/components/mt_index'
import MtVue1 from '@/components/mt_vue1'
import MtVue2 from '@/components/mt_vue2'
import MtVue3 from '@/components/mt_vue3'
import MtVueDebug from '@/components/mt_vue_debug'
import MtVueDebug1 from '@/components/mt_vue_debug1'
import MtVueDebugId from '@/components/mt_vue_debugid'

Vue.use(Router);

export default new Router({
  mode: 'history',
  routes: [
    {
      path:'/',
      name:'index',
      component:MtIndex
    },
    {
      path: '/mt',
      name: 'mt1',
      component: MtVue1
    },
    {
      path: '/2',
      component: MtVue2,
      children: [
        {path: '', name: 'empty', component: MtVueDebug},
        {path: 'mt2child1', name: 'mt2child1', component: MtVueDebug1}
      ]
    },
    {
      path: '/mt-debug/:id',
      name: 'mtid',
      component: MtVueDebugId
    },
    {
      path: '/mt3',
      name: 'mt3',
      component: MtVue3
    }
  ]
})

/**
 * 拦截路由
this.router.beforeEach(function(to,from,next){
  var login = false;
  if(!login && to.path === '/xxx'){
  //拦截 跳转到某界面 例如登录
    next('/yyy')
  }else{
  //正常跳转
    next()
  }
})
 */
